package com.yanchangapp.adapter;

import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.yanchangapp.R;
import com.yanchangapp.model.bean.ContractCommentBean;
import com.yanchangapp.model.bean.OrderCommentBean;
import com.yanchangapp.widget.ExpandLayout;
import com.zxl.baselib.util.time.TimeUtil;
import com.zxl.baselib.util.ui.ResHelper;

import java.util.List;

/**
 * Created by apple on 2019-08-08.
 * description: 订单详情 -- 审批意见表 列表
 */
public class ContractCommentAdapter extends BaseQuickAdapter<ContractCommentBean, BaseViewHolder> {
    public ContractCommentAdapter(int layoutResId, @Nullable List<ContractCommentBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, ContractCommentBean orderCommentBean) {
        baseViewHolder.setText(R.id.tvUserName, ResHelper.getString(R.string.order_comment_user_name,orderCommentBean.getApprovalPerson()));
        baseViewHolder.setText(R.id.tvTime, orderCommentBean.getApprovalDate().substring(0,10));
        baseViewHolder.setText(R.id.tvCommentName,orderCommentBean.getApprovalPerson());
        baseViewHolder.setText(R.id.tvCommentResult,orderCommentBean.getApprovalResult());
        String reason = "暂无";
        if (!TextUtils.isEmpty(orderCommentBean.getRemarks())){
            reason = orderCommentBean.getRemarks();
        }
        baseViewHolder.setText(R.id.tvCommentContent,reason);
        ImageView ivArrow = baseViewHolder.getView(R.id.ivArrow);
        ExpandLayout expandLayout = baseViewHolder.getView(R.id.expandLayout);
        expandLayout.initExpand(false,ivArrow,true);
        RelativeLayout rlHead = baseViewHolder.getView(R.id.rlHead);
        rlHead.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                    expandLayout.toggleExpand();
            }
        });
    }
}
